oracle.pg.hbase

## Class OraclePropertyGraphUtils

- java.lang.Object
- - oracle.pg.hbase.OraclePropertyGraphUtils

- All Implemented Interfaces:
    MesgConsts

      public class OraclePropertyGraphUtils
      extends Object
      implements MesgConsts

  This class contains utility functions to help manage property graphs stored in an Apache HBase Database

- - ### Field Summary

    - ### Fields inherited from interface oracle.pg.common.MesgConsts

      `ERR_ARG_CANNOT_BE_NULL, ERR_CODE_NOT_IN_LIST, ERR_DOP_CONSTRAINT, ERR_E_DS_MUSTBE_FILE_OR_IS, ERR_E_MAX_LINE_CONSTRAINT, ERR_EDGE_DIR_NOT_BOTH, ERR_GRAPH_NAME_CANT_BENULL, ERR_HIT_EXCEPTION, ERR_HIT_INTERRUPT, ERR_HIT_IO, ERR_HIT_OPGE, ERR_HIT_PARSEE, ERR_ID_CANNOT_BE_NULL, ERR_IDX_KEY_CANNOT_BE_NULL, ERR_IN_DS_EDGE_CANTBE_NULL, ERR_IN_DS_VERT_CANTBE_NULL, ERR_IN_E_FLAT_DOESNT_EXIST, ERR_IN_V_FLAT_DOESNT_EXIST, ERR_INVALID_NUM_FIELDS, ERR_INVALID_NUM_NOARG, ERR_INVALID_NUMBER, ERR_INVALID_VAL, ERR_KEY_CANNOT_BE_ID, ERR_KEY_CANNOT_BE_NULL, ERR_KEY_NOT_SET_TO, ERR_NO_ELEM_TO_BE_CONSUMED, ERR_NO_OP_SUPPORTED, ERR_NOT_IMPLEMENTED_YET, ERR_NOT_ORACLE_V_E, ERR_NUM_PART_CONSTRAINT, ERR_OFFSET_CONSTRAINT, ERR_OFFSET_E_MUST_BE_POS, ERR_OFFSET_V_MUST_BE_POS, ERR_PG_ALREADY_EXISTS, ERR_PG_NOT_EMPTY, ERR_SIZE_MUST_BE_POS, ERR_TIMEOUT_TAB_CREATION, ERR_TYPE_ID_NOT_RECO, ERR_UNSUPPORTED_VAL_TYP, ERR_USER_REQ_OP_CANCEL, ERR_V_DS_MUSTBE_FILE_OR_IS, ERR_V_MAX_LINE_CONSTRAINT, ERR_VALUE_CANNOT_BE_NULL, INFO_EMP_K_NO_P_VAL, INFO_NUL_K_NO_P_VAL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OraclePropertyGraphUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `bigIntegerToByteArray(BigInteger key)` Parse a bigInteger into a byte array of length 16.
    `static String` | `byteArrayToStr(String marker, byte[] ba)` Returns a string representation of the specified byte array
    `static String` | `bytesToHex(byte[] bytes)` Parse a byte array into a Hex-based string.
    `static boolean` | `compareFiles(String szSrcFile, String szDstFile)` Compare the content of two files
    `static void` | `copyGraph(org.apache.hadoop.conf.Configuration conf, String graphName, String newGraphName)` Copy the property graph (including its associated tables) to the specified graph name (if it is not empty).
    `static void` | `dropPropertyGraph(org.apache.hadoop.conf.Configuration conf, String szGraphName)` Drops the specified property graph (including its associated tables).
    `static byte[]` | `escape(String s)` This method escapes a string in the following manner: In one scan from left to right, a % is replaced with %25, a tab \t is replaced with %09, a newline \n is replaced with %0A, and a comma is replaced with %2c.
    `static boolean` | `existsGraph(org.apache.hadoop.conf.Configuration conf, String graphName)` Checks if the specified property graph exists in the Apache HBase database
    `static void` | `exportFlatFiles(OraclePropertyGraph pg, OutputStream osVertex, OutputStream osEdge, int dop, boolean append)` This function exports a given property graph into two flat files: one for vertices and the other for edges.
    `static void` | `exportFlatFiles(OraclePropertyGraph pg, String vertexFileName, String edgeFileName, boolean append)` This function exports a given property graph into two flat files: one for vertices and the other for edges.
    `static void` | `exportFlatFiles(OraclePropertyGraph pg, String vertexFileName, String edgeFileName, int dop, boolean append)` This function exports a given property graph into two flat files: one for vertices and the other for edges.
    `static void` | `exportGML(OraclePropertyGraph opg, OutputStream os, PrintStream psOut)` Exports all vertices/edges from the specified property graph into the output stream in GML format.
    `static void` | `exportGML(OraclePropertyGraph opg, String gmlFileName, PrintStream psOut)` Exports all vertices/edges from the specified property graph into the specified file in GML format.
    `static void` | `exportGraphML(OraclePropertyGraph opg, OutputStream os, PrintStream psOut)` Exports all vertices/edges from the specified property graph into the output stream in GraphGML format.
    `static void` | `exportGraphML(OraclePropertyGraph opg, String graphMLFileName, PrintStream psOut)` Exports all vertices/edges from the specified property graph into the specified file in GraphGML format.
    `static void` | `exportGraphSON(OraclePropertyGraph opg, OutputStream os, PrintStream psOut)` Exports all vertices/edges from the specified property graph into the output stream in GraphSON format.
    `static void` | `exportGraphSON(OraclePropertyGraph opg, String graphSonFileName, PrintStream psOut)` Exports all vertices/edges from the specified property graph into the specified file in GraphSON format.
    `static List<String>` | `getGraphNames(org.apache.hadoop.conf.Configuration conf)` List all graph names
    `static byte[][]` | `getHexSplitsWithEndpoints(String startKey, String endKey, int numRegions)` Generates an array with the splits (including the endpoints) for the specified start and end keys.
    `static InputStream` | `handleGZipInputStream(InputStream in)` Handle a GZIPInputStream.
    `static void` | `importGML(OraclePropertyGraph opg, InputStream is, PrintStream psOut)` Imports all vertices/edges from the input stream in GML format into the specified property graph.
    `static void` | `importGML(OraclePropertyGraph opg, String gmlFileName, PrintStream psOut)` Imports all vertices/edges from the specified file in GML format into the specified property graph.
    `static void` | `importGraphML(OraclePropertyGraph opg, InputStream is, PrintStream psOut)` Imports all vertices/edges from the input stream in GraphGML format into the specified property graph.
    `static void` | `importGraphML(OraclePropertyGraph opg, String graphMLFileName, PrintStream psOut)` Imports all vertices/edges from the specified file in GraphGML format into the specified property graph.
    `static void` | `importGraphSON(OraclePropertyGraph opg, InputStream is, PrintStream psOut)` Imports all vertices/edges from the input stream in GraphSON format into the specified property graph.
    `static void` | `importGraphSON(OraclePropertyGraph opg, String graphSonFileName, PrintStream psOut)` Imports all vertices/edges from the specified file in GraphSON format into the specified property graph.
    `static <E> List<E>` | `listify(Iterable<E> it)` This method converts a given Iterable instance to a List object.
    `static void` | `printByteArray(String marker, byte[] ba, PrintStream ps)` Prints a string representation of the byte array to the specified PrintStream
    `static void` | `quietlyClose(InputStream is)` Quietly closes the specified inputstream.
    `static void` | `quietlyClose(OutputStream os)` Quietly closes the specified outputstream.
    `static void` | `quietlyCloseConnection(org.apache.hadoop.hbase.client.HConnection connection)` Quietly close an HConnection object
    `static void` | `quietlyCloseConnections(org.apache.hadoop.hbase.client.HConnection[] connections)` Quietly close an array of HConnection objects
    `static void` | `quietlyShutdown(OraclePropertyGraph opg)` Quietly shutdown a property graph.
    `static void` | `renameGraph(org.apache.hadoop.conf.Configuration conf, String graphName, String newGraphName)` Renames the property graph (including its associated tables) to the specified graph name (if it does not exists or is not empty).
    `static boolean` | `sameSubArray(byte[] ba1, byte[] ba2, int iStart, int iLen)` Verifies if two byte arrays are equals from the specified start and length.
    `static <E> long` | `size(Iterable<E> it)` This method returns the number of elements in the given Iterable object.
    `static String` | `unescape(String s)` This method escapes a string in the following manner: %2C => ',' %0A => chr(10) %20 => ' ' %09 => chr(9) %25 => '%'
    `static void` | `writeValue(OutputStream os, Object value, byte[] baFieldDelimiter, SimpleDateFormat sdf)` This helper function serializes an object into the given output stream.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OraclePropertyGraphUtils

          public OraclePropertyGraphUtils()

  - ### Method Detail

    - #### bigIntegerToByteArray

          public static byte[] bigIntegerToByteArray(BigInteger key)

      Parse a bigInteger into a byte array of length 16.
      Parameters:
        `key` - the big integer to be parsed
      Returns:
        a byte array of length 16, representing the number.

    - #### byteArrayToStr

          public static String byteArrayToStr(String marker,
                              byte[] ba)

      Returns a string representation of the specified byte array
      Parameters:
        `marker` - an additional marker to be printed with the byte array
        `ba` - the byte array to be printed
      Returns:
        a string representation of the byte array.

    - #### bytesToHex

          public static String bytesToHex(byte[] bytes)

      Parse a byte array into a Hex-based string.
      Parameters:
        `bytes` - the byte array to be parsed.
      Returns:
        a Hex-based string

    - #### compareFiles

          public static boolean compareFiles(String szSrcFile,
                             String szDstFile)
                                      throws IOException

      Compare the content of two files
      Throws:
        `IOException`

    - #### copyGraph

          public static void copyGraph(org.apache.hadoop.conf.Configuration conf,
                       String graphName,
                       String newGraphName)
                                throws IOException,
                                       Exception

      Copy the property graph (including its associated tables) to the specified graph name (if it is not empty). This operation will not copy existing indices into the new graph.
      Parameters:
        `conf` - the Apache HBase configuration
        `graphName` - the OraclePropertyGraph to rename.
        `newGraphName` - the new name of the graph.
      Throws:
        `IOException`
        `Exception`

    - #### dropPropertyGraph

          public static void dropPropertyGraph(org.apache.hadoop.conf.Configuration conf,
                               String szGraphName)
                                        throws IOException,
                                               Exception

      Drops the specified property graph (including its associated tables).
      Parameters:
        `conf` - the Configuration object with all the HBase connection information.
        `szGraphName` - the name of the graph to drop.
      Throws:
        `IOException`
        `Exception`

    - #### escape

          public static byte[] escape(String s)

      This method escapes a string in the following manner: In one scan from left to right, a % is replaced with %25, a tab \t is replaced with %09, a newline \n is replaced with %0A, and a comma is replaced with %2c.

    - #### existsGraph

          public static boolean existsGraph(org.apache.hadoop.conf.Configuration conf,
                            String graphName)
                                     throws IOException

      Checks if the specified property graph exists in the Apache HBase database
      Parameters:
        `conf` - the Apache HBase configuration
        `graphName` - the name of the property graph
      Throws:
        `IOException`

    - #### exportFlatFiles

          public static void exportFlatFiles(OraclePropertyGraph pg,
                             OutputStream osVertex,
                             OutputStream osEdge,
                             int dop,
                             boolean append)
                                      throws IOException,
                                             FileNotFoundException,
                                             InterruptedException

      This function exports a given property graph into two flat files: one for vertices and the other for edges.
      Parameters:
        `osVertex` - output stream to store the serialized vertices
        `osEdge` - output stream to store the serialized edges
      Throws:
        `IOException`
        `FileNotFoundException`
        `InterruptedException`

    - #### exportFlatFiles

          public static void exportFlatFiles(OraclePropertyGraph pg,
                             String vertexFileName,
                             String edgeFileName,
                             boolean append)
                                      throws IOException,
                                             FileNotFoundException,
                                             InterruptedException

      This function exports a given property graph into two flat files: one for vertices and the other for edges.
      Throws:
        `IOException`
        `FileNotFoundException`
        `InterruptedException`

    - #### exportFlatFiles

          public static void exportFlatFiles(OraclePropertyGraph pg,
                             String vertexFileName,
                             String edgeFileName,
                             int dop,
                             boolean append)
                                      throws IOException,
                                             FileNotFoundException,
                                             InterruptedException

      This function exports a given property graph into two flat files: one for vertices and the other for edges.
      Throws:
        `IOException`
        `FileNotFoundException`
        `InterruptedException`

    - #### exportGML

          public static void exportGML(OraclePropertyGraph opg,
                       OutputStream os,
                       PrintStream psOut)
                                throws IOException

      Exports all vertices/edges from the specified property graph into the output stream in GML format.
      Parameters:
        `opg` - the property graph to be exported.
        `os` - the outputstream where the property graph data will be exported
        `psOut` -
      Throws:
        `IOException`

    - #### exportGML

          public static void exportGML(OraclePropertyGraph opg,
                       String gmlFileName,
                       PrintStream psOut)
                                throws IOException

      Exports all vertices/edges from the specified property graph into the specified file in GML format.
      Parameters:
        `opg` - the property graph to be exported.
        `gmlFileName` - the name of the file where the data should be written
        `psOut` -
      Throws:
        `IOException`

    - #### exportGraphML

          public static void exportGraphML(OraclePropertyGraph opg,
                           OutputStream os,
                           PrintStream psOut)
                                    throws IOException

      Exports all vertices/edges from the specified property graph into the output stream in GraphGML format.
      Parameters:
        `opg` - the property graph to be exported.
        `os` - the outputstream where the property graph data will be exported
        `psOut` -
      Throws:
        `IOException`

    - #### exportGraphML

          public static void exportGraphML(OraclePropertyGraph opg,
                           String graphMLFileName,
                           PrintStream psOut)
                                    throws IOException

      Exports all vertices/edges from the specified property graph into the specified file in GraphGML format.
      Parameters:
        `opg` - the property graph to be exported.
        `graphMLFileName` - the name of the file where the data should be written
      Throws:
        `IOException`

    - #### exportGraphSON

          public static void exportGraphSON(OraclePropertyGraph opg,
                            OutputStream os,
                            PrintStream psOut)
                                     throws IOException

      Exports all vertices/edges from the specified property graph into the output stream in GraphSON format.
      Parameters:
        `opg` - the property graph to be exported.
        `os` - the outputstream where the property graph data will be exported
      Throws:
        `IOException`

    - #### exportGraphSON

          public static void exportGraphSON(OraclePropertyGraph opg,
                            String graphSonFileName,
                            PrintStream psOut)
                                     throws IOException

      Exports all vertices/edges from the specified property graph into the specified file in GraphSON format.
      Parameters:
        `opg` - the property graph to be exported.
        `graphSonFileName` - the name of the file where the data should be written
      Throws:
        `IOException`

    - #### getGraphNames

          public static List<String> getGraphNames(org.apache.hadoop.conf.Configuration conf)

      List all graph names

    - #### getHexSplitsWithEndpoints

          public static byte[][] getHexSplitsWithEndpoints(String startKey,
                                           String endKey,
                                           int numRegions)

      Generates an array with the splits (including the endpoints) for the specified start and end keys.
      Parameters:
        `startKey` - the start key of the splits as a byte array.
        `endKey` - the end key of the splits as a byte array.
        `numRegions` - the number of splits to define.
      Returns:
        an array of byte[] with the split keys. The size of this array is the numRegions + 1 (as startKey and endKey are included in the array).

    - #### handleGZipInputStream

          public static InputStream handleGZipInputStream(InputStream in)
                                                   throws IOException

      Handle a GZIPInputStream.
      Throws:
        `IOException`

    - #### importGML

          public static void importGML(OraclePropertyGraph opg,
                       InputStream is,
                       PrintStream psOut)
                                throws IOException

      Imports all vertices/edges from the input stream in GML format into the specified property graph.
      Parameters:
        `opg` - the property graph to be exported.
        `is` - the inputstream where the property graph data will be imported
      Throws:
        `IOException`

    - #### importGML

          public static void importGML(OraclePropertyGraph opg,
                       String gmlFileName,
                       PrintStream psOut)
                                throws IOException

      Imports all vertices/edges from the specified file in GML format into the specified property graph.
      Parameters:
        `opg` - the property graph to be exported.
        `gmlFileName` - the file name where the property graph data will be imported
      Throws:
        `IOException`

    - #### importGraphML

          public static void importGraphML(OraclePropertyGraph opg,
                           InputStream is,
                           PrintStream psOut)
                                    throws IOException

      Imports all vertices/edges from the input stream in GraphGML format into the specified property graph.
      Parameters:
        `opg` - the property graph to be exported.
        `is` - the inputstream where the property graph data will be imported
      Throws:
        `IOException`

    - #### importGraphML

          public static void importGraphML(OraclePropertyGraph opg,
                           String graphMLFileName,
                           PrintStream psOut)
                                    throws IOException

      Imports all vertices/edges from the specified file in GraphGML format into the specified property graph.
      Parameters:
        `opg` - the property graph to be exported.
        `graphMLFileName` - the file name where the property graph data will be imported
      Throws:
        `IOException`

    - #### importGraphSON

          public static void importGraphSON(OraclePropertyGraph opg,
                            InputStream is,
                            PrintStream psOut)
                                     throws IOException

      Imports all vertices/edges from the input stream in GraphSON format into the specified property graph.
      Parameters:
        `opg` - the property graph to be exported.
        `is` - the inputstream where the property graph data will be imported
      Throws:
        `IOException`

    - #### importGraphSON

          public static void importGraphSON(OraclePropertyGraph opg,
                            String graphSonFileName,
                            PrintStream psOut)
                                     throws IOException

      Imports all vertices/edges from the specified file in GraphSON format into the specified property graph.
      Parameters:
        `opg` - the property graph to be exported.
        `graphSonFileName` - the file name where the property graph data will be imported
      Throws:
        `IOException`

    - #### listify

          public static <E> List<E> listify(Iterable<E> it)

      This method converts a given Iterable instance to a List object.
      Parameters:
        `it` - an Iterable instance. It can be NULL.

    - #### printByteArray

          public static void printByteArray(String marker,
                            byte[] ba,
                            PrintStream ps)

      Prints a string representation of the byte array to the specified PrintStream
      Parameters:
        `marker` - an additional marker to be printed with the byte array
        `ba` - the byte array to be printed

    - #### quietlyClose

          public static void quietlyClose(InputStream is)

      Quietly closes the specified inputstream.
      Parameters:
        `is` - the inputstream to close.

    - #### quietlyClose

          public static void quietlyClose(OutputStream os)

      Quietly closes the specified outputstream.
      Parameters:
        `os` - the outputstream to close.

    - #### quietlyCloseConnection

          public static void quietlyCloseConnection(org.apache.hadoop.hbase.client.HConnection connection)

      Quietly close an HConnection object
      Parameters:
        `connection` - the HConnection to be closed.

    - #### quietlyCloseConnections

          public static void quietlyCloseConnections(org.apache.hadoop.hbase.client.HConnection[] connections)

      Quietly close an array of HConnection objects
      Parameters:
        `connections` - the array of HConnections to be closed.

    - #### quietlyShutdown

          public static void quietlyShutdown(OraclePropertyGraph opg)

      Quietly shutdown a property graph.
      Parameters:
        `opg` - the property graph to be shutdown.

    - #### renameGraph

          public static void renameGraph(org.apache.hadoop.conf.Configuration conf,
                         String graphName,
                         String newGraphName)
                                  throws IOException,
                                         Exception

      Renames the property graph (including its associated tables) to the specified graph name (if it does not exists or is not empty). This operation will not take into account existing indices. Indices should be removed before calling this operation and re-executed using the new graph instance.
      Parameters:
        `conf` - the Apache HBase configuration
        `graphName` - the OraclePropertyGraph to rename.
        `newGraphName` - the new name of the graph.
      Throws:
        `IOException`
        `Exception`

    - #### sameSubArray

          public static boolean sameSubArray(byte[] ba1,
                             byte[] ba2,
                             int iStart,
                             int iLen)

      Verifies if two byte arrays are equals from the specified start and length.
      Parameters:
        `ba1` - the first byte array to compare
        `ba2` - the second byte array to compare
        `iStart` - the start of the sub-array to compare
        `iLen` - the length of the sub-array to compare
      Returns:
        true if the sub-arrays are equal, else return false.

    - #### size

          public static <E> long size(Iterable<E> it)

      This method returns the number of elements in the given Iterable object.

    - #### unescape

          public static String unescape(String s)

      This method escapes a string in the following manner: %2C => ',' %0A => chr(10) %20 => ' ' %09 => chr(9) %25 => '%'

    - #### writeValue

          public static void writeValue(OutputStream os,
                        Object value,
                        byte[] baFieldDelimiter,
                        SimpleDateFormat sdf)
                                 throws IOException

      This helper function serializes an object into the given output stream. The accepted object type of value can be String, Float, Integer, Double, Date, Boolean, and Serializable.
      Throws:
        `IOException`

Copyright © 2015 Oracle and/or its affiliates. All Rights Reserved.